<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>增加</title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css"/>
</head>
<body>
<form class="layui-form" action="">
    <div class="mainBox">
        <div class="main-container">
<!--            <div class="layui-form-item layui-inline">-->
<!--                <label class="layui-form-label">编号</label>-->
<!--                <div class="layui-input-inline">-->
<!--                    <input type="text" name="id" placeholder="" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="jname" placeholder="" class="layui-input">
                </div>
            </div>
<!--            <div class="layui-form-item layui-inline">-->
<!--                <label class="layui-form-label">上传时间</label>-->
<!--                <div class="layui-input-inline">-->
<!--                    <input  type="date" name="posttime" placeholder="" class="layui-input">-->
<!--                </div>-->
<!--            </div>-->

            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">上传简历</label>
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" id="layui-btn">
                        <i class="layui-icon">&#xe67c;</i>上传按钮
                    </button>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">文件地址</label>
                <div class="layui-input-block">
                    <input type="text" name="fileUrl" id="file-address" value="" lay-verify="required"
                           class="layui-input">
                </div>
            </div>

            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">手机号</label>
                <div class="layui-input-inline">
                    <input type="text" name="phone" placeholder="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item layui-inline">
                <label class="layui-form-label">岗位编号</label>
                <div class="layui-input-inline">
                    <input type="number" id="jobid" name="jobid" placeholder="" class="layui-input">
                </div>
            </div>
        </div>
    </div>
    <div class="bottom">
        <div class="button-container">
            <button type="submit" class="pear-btn pear-btn-primary pear-btn-sm" lay-submit
                    lay-filter="user-save">
                <i class="layui-icon layui-icon-ok"></i>
                提交
            </button>
            <button type="reset" class="pear-btn pear-btn-sm">
                <i class="layui-icon layui-icon-refresh"></i>
                重置
            </button>
        </div>
    </div>
</form>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['form', 'jquery', 'upload'], function () {
        let form = layui.form;
        let $ = layui.jquery;
        form.on('submit(user-save)', function (data) {
            $.ajax({
                url: window.BASEPATH + 'seeker/upload',
                data: data.field,
                type: 'post',
                success: function (result) {
                    if (result.code == 0) {
                        layer.msg(result.msg, {
                            icon: 1,
                            time: 1000
                        }, function () {
                            parent.layer.close(parent.layer.getFrameIndex(window
                                .name)); //关闭当前页
                            parent.layui.table.reload("user-table");
                        });
                    } else {
                        layer.msg(result.msg, {
                            icon: 2,
                            time: 1000
                        });
                    }
                }
            })
            return false;
        });
    });

	layui.use('upload', function () {
		let upload = layui.upload;
		let $ = layui.jquery;

		//执行实例
		let uploadInst = upload.render({
			elem: '#layui-btn' //绑定元素
             ,url: window.BASEPATH + 'seeker/doresume' //上传接口
            ,accept:'file'
            // ,field:'file'
            ,multiple:true
			, done: function (result) {
				//上传完毕回调
				if (result.code == 0) {
					layer.alert(result.msg);

					 let imagUrl = result.data;
					console.log(imagUrl);
					//获取上传成功之后图片路径
					$('#file-address').val(imagUrl);
				} else {
					layer.alert(res.msg)
				}
			}
			, error: function () {
				//请求异常回调
			}
		});
	});


</script>
</body>
</html>
